package com.sz.stock.mapper;

import com.sz.stock.model.Entrust;
import com.sz.stock.model.EntrustExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

@Component
public interface EntrustMapper {
    int countByExample(EntrustExample example);

    int deleteByExample(EntrustExample example);

    int deleteByPrimaryKey(Integer stockEntrustId);

    int insert(Entrust record);

    int insertSelective(Entrust record);

    List<Entrust> selectByExample(EntrustExample example);
    //    查买入委托(用户以外的,股票代码一样的,操作是:买入的,状态是: 未成交或部成的,委托价大于或等于的)


    @Select("select * from T_STOCK_ENTRUST where STOCK_ENTRUST_USERID!=#{param1} and stock_entrust_code=#{param2} " +
            "and stock_entrust_operate='买入' and stock_entrust_status not in ('全部成交','部撤','全部撤单') and stock_entrust_money>=#{param3} order by stock_entrust_money desc, stock_entrust_time asc")
    List<Entrust> selectCondition(int a,String b,int c);  //用户id 股票代码 委托金额

    Entrust selectByPrimaryKey(Integer stockEntrustId);

    int updateByExampleSelective(@Param("record") Entrust record, @Param("example") EntrustExample example);

    int updateByExample(@Param("record") Entrust record, @Param("example") EntrustExample example);

    int updateByPrimaryKeySelective(Entrust record);

    int updateByPrimaryKey(Entrust record);

    @Select("select * from T_STOCK_ENTRUST where stock_entrust_code=#{param1} and stock_entrust_operate = '卖出' and stock_entrust_status in('未成交', '部成', '部撤') and stock_entrust_money<=#{param2} order by stock_entrust_money asc,stock_entrust_time asc")
    List<Entrust> selectSellEntrust(String code, float money);

}